import ajaxResult from '../models/apis/ajaxResult';

export abstract class clientBase {
  public buildSuccessResult<T>(data?: T, msg?: string): ajaxResult<T> {
    let r = new ajaxResult<T>();
    r.success = true;
    r.message = msg;
    r.data = data;
    return r;
  }

  public buildFailedResult<T>(msg?: string): ajaxResult<T> {
    let r = new ajaxResult<T>();
    if (msg)
      r.message = msg;
    r.success = false;
    return r;
  }

  public buildExceptionResult<T>(exc: Error): ajaxResult<T> {
    let r = new ajaxResult<T>();
    r.message = exc.message;
    r.success = false;
    return r;
  }
}